<?php

class Light_View_Helper_Identity extends Light_View_Helper_Abstract
{
    /**
     * @var Users_Model_Entity_User
     */
    protected $_identity;

    /**
     * @return Users_Model_Entity_User
     */
    public function identity()
    {
        if ($this->_identity !== null) {
            return $this->_identity;
        }

        if (isset($_SESSION[LIGHT_SESSION_NAME]['identity'])) {
            $this->_identity = unserialize($_SESSION[LIGHT_SESSION_NAME]['identity']);
            $this->_identity->setTable(new Users_Model_Index());
        } else {
            $this->_identity = false;
        }

        return $this->_identity;
    }
}